home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_069 / icontype / icontype.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  74 lines

  1.  
  2. /* IconType - a program to change the type of icon. Useful for changing
  3.  *            an icon's type after editing with IconEd.
  4.  *
  5.  * Icon types are Disk, Drawer, Tool, Project, Garbage, and Device
  6.  *
  7.  * Syntax: icontype <filename> <type>
  8.  *
  9.  * Example: icontype test.info project
  10.  *          (changes the icon "test.info" to a project icon)
  11.  *
  12.  * by: Larry Phillips, CIS 76703,4322
  13.  */
  14.  
  15. #include "exec/types.h"
  16. #include "exec/nodes.h"
  17. #include "exec/lists.h"
  18. #include "exec/libraries.h"
  19. #include "exec/ports.h"
  20. #include "exec/interrupts.h"
  21. #include "exec/io.h"
  22. #include "exec/memory.h"
  23. #include "libraries/dos.h"
  24. #include "libraries/dosextens.h"
  25.  
  26. extern struct FileHandle *Open();
  27.  
  28. main (argc,argv)
  29. int argc;
  30. char *argv[];
  31.  
  32. {
  33.   struct FileHandle *file;
  34.   unsigned char buf;
  35.   static char *type[7] = { "","disk","drawer","tool","project","garbage","device" };
  36.   if ((argc < 3)||(argc > 3))
  37.    {
  38.     puts("Usage: IconType <filename> <type>\nTypes are disk, drawer, tool, project, garbage, device.");
  39.    }
  40.   else
  41.    {
  42.     if ((file = Open(argv[1],MODE_OLDFILE))==0)
  43.       {
  44.         puts ("Unable to open icon file.");
  45.         Exit();
  46.       }
  47.  
  48.     Read (file,&buf,1L);
  49.  
  50.     if (buf == 0xE3)
  51.       {
  52.         Read (file,&buf,1L);
  53.         if (buf == 0x10)
  54.           {
  55.             Seek (file, 48L,(long) OFFSET_BEGINNING);
  56.             tolower (argv[2]);
  57.             for (buf = 1;buf < 7;buf++)
  58.                if (strcmp(argv[2],type[buf])==0)
  59.                  {
  60.                    Write (file,&buf,1L);
  61.                    break;
  62.                  }
  63.             if (buf == 7) puts ("Invalid icon type.");
  64.             printf("%d ",buf);
  65.           }
  66.         else puts ("Not an icon file.");
  67.       }
  68.     else puts ("Not an icon file.");
  69.  
  70.     Close (file);
  71.     Exit  ();
  72.   }
  73. }
  74.